#include<stdio.h>
int main ()
{
	int k,t;int n;int A=0,B=0;
	scanf("%d",&t);
	for(k=1;k<=t;k++)
	{
		A=0;B=0;
		scanf("%d",&n);
		while(n!=0)
		{
			if(n%2==1)
		{
			n=n-1;
			B++;
		}
		else
		{
			n=n/2;
			A++;
		}
		}
		printf("%d\n",B);
	}
	return 0;
}
